T,n = map(int,input().split())
for _ in range(T):
    nums = input().split()
    a = nums.count("0")
    b = nums.count("1")
    print(abs(a-b))
